﻿<?php
include("function.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录</title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	font-size:12px;
	font-family:Verdana, Geneva,"宋体";
	background:url(src/img/login_back.png) #FFF;
	background-position: center 0;
    background-repeat: no-repeat;
    background-attachment: fixed;
	}
#error_msg{
	background-color:#F00;
	color:#FFF;
	text-align:center;
	height:40px;
	width:100%;
	position:absolute;
	left:0px;
	top:0px;
	z-index:999;
	padding-top:15px;
	}
form{
	margin-top:325px;
	text-align:center;

	}
#mgr{
	margin-top:325px;
	text-align:center;
	}
.input_box{
	border:2px #900 solid;
	padding:2px;
	height:24px;
	font-family:Verdana;
	font:bolder;
	background:#FFC;
	}	
</style>

</head>
<body onload="user_form_show();">
<?php
//获取返回的错误信息并显示
if(isset($_GET["error_msg"])){
	echo "<div id='error_msg'>".$_GET["error_msg"]."</div>";
	}

if(isset($_SESSION["user_id"])){
    echo "<div id='mgr'>".$_SESSION["user_id"].", <a href='main.php'>点击返回管理</a><br>点击进入个人中心</div>";
	}else{
?>
<form id="user_form" name="user_form" method="post" action="login_in.php?action=user_login" onsubmit="return check_user_form();" >
    <label>用户名：
        <input name="user_id" type="text" class="input_box" id="user_id" />
    </label>
    <label>密码：
        <input name="user_pwd" type="password" class="input_box" id="user_pwd" />
    </label>
    <label>
        <input name="" type="submit" value="登录" />
    </label>
  <label>
        <input name="" type="button" value="管理员登录" onclick="admin_form_show();"/>
  </label>
</form>
<?php
}
?>

<!--admin_login -->
<form id="admin_form" name="admin_form" method="post" action="login_in.php?action=admin_login" onsubmit="return check_admin_form();" style="display:none;">
    <label>用户名：
        <input name="admin_id" type="text" class="input_box" id="admin_id" />
    </label>
    <label>密码：
        <input name="admin_pwd" type="password" class="input_box" id="admin_pwd" />
    </label>
    <label>验证码：
        <input name="yzm" type="text" class="input_box" id="yzm" size="8" maxlength="6" />
        <img src="src/yzm.php" align="absmiddle" alt="点击刷新" onclick="this.src='src/yzm.php#'+new Date().getTime()" onmouseover="showhand(this);"/>
    </label>
    <label>
        <input name="sss" type="submit" value="登录" id="sss" />
    </label>
    <label>
        <input name="input" type="button" value="普通登录" onclick="user_form_show();"/>
    </label>
</form>

<div style="height:100px;" >
</div>
<div style="text-align:center; font:Verdana; color:#39F;">
  2009 <a href="http://icinfo.cn" style="color:#39F; text-decoration:none;">icinfo.cn</a> Doc_Mgr v1.0.0.45 by Mr.l
</div>

<script language="JavaScript"> 
//检查表单
function check_user_form(){
	if(document.getElementById("user_id").value.length<2){
		alert("用户名长度有误！\n注意：用户名长度在6到16位之间。");
		return false; 
		}
	if(document.getElementById("user_pwd").value.length<2){
		alert("密码长度有误！\n注意：密码长度在6到16位之间。");
		return false; 
		}	
	}

function check_admin_form(){
	if(document.getElementById("admin_id").value.length<2){
		alert("用户名长度有误！\n注意：用户名长度在6到16位之间。");
		return false; 
		}
	if(document.getElementById("admin_pwd").value.length<2){
		alert("密码长度有误！\n注意：密码长度在6到16位之间。");
		return false; 
		}		
	if(document.getElementById("yzm").value.length!=6){
		alert("验证码长度有误！\n注意：验证码长度为6位数字或大写字母。");
		return false; 
		}	
	}
	
function admin_form_show(){
	document.getElementById("user_form").style.display="none";
	document.getElementById("admin_form").style.display="block";
	document.getElementById("admin_id").focus();
	
	}
function user_form_show(){
	document.getElementById("user_form").style.display="block";
	document.getElementById("admin_form").style.display="none";
	document.getElementById("user_id").focus();
	}

function showhand(obj){//显示手型，未使用
	obj.style.cursor =	"hand";
}
function load_msg(){
	if(document.getElementById("error_msg").innerHTML.length>0){
		document.title=document.getElementById("error_msg").innerHTML;
		}
	}	
window.onload=load_msg();
</script>



</body>
</html>